import { createRouter, createWebHashHistory } from "vue-router";
import FrontLayout from "@/pages/Front.vue";
import AdminLayout from "@/pages/Admin.vue";

export default createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: "/front",
      component: FrontLayout,
      children: [
        {
          path: "home",
          component: () => import("../pages/front/home.vue"),
        },
        {
          path: "hospital",
          component: () => import("../pages/front/hospital.vue"),
        },
      ],
    },
    {
      path: "/",
      component: AdminLayout,
      redirect: "/front/home", // 重定向到主页
      children: [
        {
          path: "home",
          component: () => import("@/pages/admin/home.vue"),
        },
      ],
    },
    {
      path: "/:pathMatch(.*)",
      component: () => import("../pages/NotFound.vue"),
    },
    {
      path: "/login",
      component: () => import("@/pages/Login.vue"),
    },
  ],
  scrollBehavior() {
    return {
      top: 0,
    };
  },
});
